/*
 * @Description: 联系信息
 * @Author: iamsmiling
 * @Date: 2021-06-13 09:11:12
 * @LastEditTime: 2021-06-13 10:04:05
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/components/topic_card/topic_card.dart';
import 'package:credit_business_circle/domain/local/topic/topic_entity.dart';
import 'package:credit_business_circle/domain/remote/topic/topic_log_entity.dart';
import 'package:credit_business_circle/pages/mine/children/my_contatcs/my_contacts_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class MyContactsPage extends GetView<MyContactsController> {
  const MyContactsPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("联系信息"),
      ),
      body: GetBuilder<MyContactsController>(
        builder: (_) {
          return ListView.builder(
              padding: EdgeInsets.symmetric(horizontal: R.dimen.dp10),
              itemCount: _.list.length,
              itemBuilder: (BuildContext context, int i) {
                TopicLogEntity log = _.list[i];
                return Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                        margin: EdgeInsets.only(
                            top: R.dimen.dp20, bottom: R.dimen.dp13),
                        child: Text(
                          log.date,
                          style: TextStyle(
                              fontSize: R.dimen.sp12, color: R.color.ff666666),
                        )),

                    for (TopicEntity topic in log.topics)
                      Stack(
                        children: [
                          TopicCard(
                            topic: topic,
                            borderColor: R.color.transparent,
                            margin: EdgeInsets.only(bottom: R.dimen.dp10),
                            bannerVisible: false,
                            bottomRightBuilder: (BuildContext context) {
                              return GestureDetector(
                                onTap: () => _.remove(log, topic),
                                child: Row(
                                  children: [
                                    Image.asset(R.image.trash,
                                        height: R.dimen.sp11,
                                        color: R.color.ffef4408),
                                    Container(
                                      margin:
                                          EdgeInsets.only(left: R.dimen.dp6),
                                      child: Text(
                                        "删除",
                                        style: TextStyle(
                                            fontSize: R.dimen.sp11,
                                            color: R.color.ffef4408),
                                      ),
                                    )
                                  ],
                                ),
                              );
                            },
                          ),
                        ],
                      )
                    // Expanded(
                    //   child: AutoList(
                    //     items: log.topics,
                    //     duration: const Duration(milliseconds: 375),
                    //     itemBuilder: (BuildContext context, TopicEntity topic) {
                    //       return TopicCard(topic: topic);
                    //     },
                    //   ),
                    // )
                  ],
                );
              });
        },
      ),
    );
  }
}
